/*
 *  POJ1416: Shredding Company
 */

/*-------- Includes --------*/
#include <iostream>
#include <cstring>
#include <cstdlib>

using namespace std;

/*-------- Types --------*/

/*-------- Global Variables --------*/
int tgt;    // target number
int org[8]; // original number to be shredded
int nOrg;   // length of org[]
int brk[8]; // break points
int nBrk;   // number of break points
// result storage
int rbrk[8];
int rnbk;
int rnum;

bool isFound;
bool isTie;

/*-------- Function Prototypes --------*/
void dfs(int ptr, int num);

/*-------- Main Function --------*/
int main(int argc, char const *argv[])
{
    char cstr[8];

    while (cin >> tgt >> cstr && tgt) {
        // string number to array number
        nOrg = strlen(cstr);
        for (int i = 0; i < nOrg; i++)
            org[i] = cstr[i] - '0';

        int num = atoi(cstr);   // array number to real number

        // special rule 1: original number is equal to target number
        if (num == tgt) {
            cout << num << " " << num << endl;
            continue;
        }

        // special rule 2: minimum of combination is greater than target number
        int sum = 0;

        for (int i = 0; i < nOrg; i++) sum += org[i];
        if (sum > tgt) {
            cout << "error" << endl;
            continue;
        }

        // depth first search
        nBrk    = 0;
        brk[0]  = -1;
        isFound = false;
        isTie   = false;
        dfs(0, 0);

        if (isFound) {
            if (isTie) {
                cout << "rejected" << endl;
                continue;
            }

            cout << rnum;

            for (int i = 0; i < rnbk; i++) {
                cout << " ";
                for (int j = rbrk[i] + 1; j <= rbrk[i + 1]; j++)
                    cout << org[j];
            }
            cout << endl;
        }
    }

    return 0;
}

/*-------- Functions --------*/
void dfs(int ptr, int num)
{
    // base case: reach the bottom
    if (ptr == nOrg) {
        if (isFound) {
            if (rnum == num) {
                isTie = true;
                return;
            } else if (rnum > num) {
                return;
            }
        }

        // update result storage
        isFound = true;
        isTie   = false;
        rnum    = num;
        rnbk    = nBrk;
        memcpy(rbrk, brk, (nBrk + 1) * sizeof(int));
    }

    for (int i = ptr; i < nOrg; i++) {
        int part = 0;

        for (int j = brk[nBrk] + 1; j <= i; j++)
            part = part * 10 + org[j];

        // cut off
        if (num + part > tgt) break;

        brk[++nBrk] = i;

        dfs(i + 1, num + part);

        // revert for backtracing
        nBrk--;
    }
}
